
<#include "/common/head.html"/>
<input type="hidden" name="productId" value="${goods.productid!''}" ></input>
 <div class="easyui-panel addPage" data-options="fit:true,border:false,novalidate:true">
    <form class="easyui-form" id="ff" method="post" data-options="novalidate:true">
        <table class="table1">
        	
            <tr>
           		<th><span>商品名称：</span></th>
               	<td>
               		<div class="wrap_input"><input class="easyui-textbox" type="text" name="goodsName" value="${goods.goodsname!''}" data-options="fit:true"  disabled="disabled"></input></div>
           		</td>
           	</tr>
            <tr>	
           		<th><span>商品售价：</span></th>
               	<td>
               		<div class="wrap_input"><input class="easyui-textbox" type="text" name="commodityprice_test"  id="commodityprice_test"  data-options="fit:true" disabled="disabled"></input>
               		</div>
           		</td>
            </tr>
            <input  type="hidden" name="commodityprice"  id="commodityprice"  value="${goods.marketprice!''}"></input>
            <input type="hidden" id="getCommod" value="${goods.marketprice/100!''}" data-options="fit:true" ></input>
             <tr>	
           		<th><span>商品类别：</span></th>
               	<td>
               		<div class="wrap_input"><input class="easyui-textbox" type="text" name="" id="merchandise" value="${goods.goodstype!''}" data-options="fit:true" disabled="disabled"></input>
               		<input class="easyui-textbox" type="hidden" name="merchandise" value="${goods.goodstype!''}" data-options="fit:true" disabled="disabled"></input>
               		</div>
           		</td>
            </tr>
              <tr>	
           		<th><span>库存：</span></th>
               	<td>
               		<div class="wrap_input"><input class="easyui-textbox" type="text" name="currentinventory" value="${goods.storedcount!''}" data-options="fit:true" disabled="disabled"></input></div>
           		</td>
            </tr>
         <!--     <tr>	
           		<th><span>小图路径：</span></th>
               	<td>
               		<div class="wrap_input"><input class="easyui-textbox" type="text" name="smallpic" value="${goods.smallpic!''}" data-options="fit:true" disabled="disabled"></input></div>
           		</td>
            </tr>  --> 
               <tr>	
           		<th><span>总需份额：</span></th>
               	<td>
               		<div class="wrap_input"><input class="easyui-textbox" type="text" name="partion" value="" data-options="required:true"></input></div>
           		</td>
              </tr>
               <tr>	
           		<th><span>每份额：</span></th>
               	<td>
               		<div class="wrap_input"><input class="easyui-textbox" type="text" name="perpartion" value="" data-options="required:true"></input></div>
           		</td>
            </tr>
            
             <tr>	
           		<th><span>方案编号：</span></th>
               	<td>
               		<div class="wrap_input"><input class="easyui-textbox" type="text" name="competitionId" value="" data-options="required:true"></input></div>
           		</td>
            </tr>
            
             <tr>	
           		<th><span>分享标题：</span></th>
               	<td>
               		<div class="wrap_input"><input class="easyui-textbox" type="text" name="sharetitle" value="" data-options="required:true"></input></div>
           		</td>
            </tr>
            
                  <tr>	
           		<th><span>分享内容：</span></th>
               	<td>
               		<div class="wrap_input"><input class="easyui-textbox" type="text" name="sharecontent" value="" data-options="required:true"></input></div>
           		</td>
            </tr> 
            
               <tr>	
           		<th><span>开始时间：</span></th>
               	<td>
 	      <input class="easyui-datetimespinner" type="text" name="startTime" value="" id="startTime" style="width:180px;" data-options="showSeconds:true">           		

	          </td>
            </tr>
               <tr>	
           		<th><span>结束时间：</span></th>
               	<td>
       <input class="easyui-datetimespinner" type="text" name="endTime" value=""  id="endTime" style="width:180px;" data-options="showSeconds:true">           		
               	 
        		</td>
            </tr>
         
            <tr>
           		<th><span>下一期间隔时间：</span></th>
               	<td>
               		<div class="wrap_input"><input class="easyui-textbox" type="text" name="nextInterval" value="" data-options="required:true" ></input>(单位：h)</div>
           		</td>
            </tr>
        </table>
    </form>
</div>
<script>

top.window.subPage.save = save;


function save() {
	var startTime=$("#startTime").val();
	var endTime=$("#endTime").val();
	if(startTime>=endTime){
	showMsg("开始时间必须小于结束时间");
	}else{
		if($("#ff").form('enableValidation').form('validate')) {
			$.post("add", getParam(), function(data) {
				if ("success"==data.result){
					top.window.closeWindow();
					top.window.subPage.loadCurrDatagrid();
				} else {
					showMsg(data.msg);
				}
				return ;
			});
		}
	}
}

function getParam() {

		var param = {	     
	       	    "activityPlan.goodsName": $.trim($(":input[name='goodsName']").val()), 
	       	    "activityPlan.commodityprice": $.trim($(":input[name='commodityprice']").val()),      	
	       	    "activityPlan.merchandise": $.trim($(":input[name='merchandise']").val()), 
	       	    "activityPlan.currentinventory": $.trim($(":input[name='currentinventory']").val()),    	    
	         	//"activityPlan.smallpic": $.trim($(":input[name='smallpic']").val()),
	         	
	       	    "activityPlan.partion": $.trim($(":input[name='partion']").val()), 
	       	    "activityPlan.perpartion": $.trim($(":input[name='perpartion']").val()), 
	       	    "activityPlan.competitionId": $.trim($(":input[name='competitionId']").val()), 
	       	    "activityPlan.startTime": $.trim($(":input[name='startTime']").val()),
	       	 	"activityPlan.endTime": $.trim($(":input[name='endTime']").val()),
	       	    "activityPlan.nextInterval": $.trim($(":input[name='nextInterval']").val()),
	       	 	"activityPlan.productId": $.trim($(":input[name='productId']").val()),
	       	    "activityPlan.sharetitle": $.trim($(":input[name='sharetitle']").val()),
	       	    "activityPlan.sharecontent": $.trim($(":input[name='sharecontent']").val()),
		};
		for(key in param) {
			if(!param[key]) {
				delete param[key];
			}
		}
		return param;
	
}

var mer=$("#merchandise").val();
if(mer=='0'){
	$("#merchandise").val("实物");
}else if(mer=='1'){
	$("#merchandise").val("数字商品");
}

//扩展js
   var today = new Date();
   var day = today.getDate();
   var month = today.getMonth() + 1;
   var year = today.getYear();
   var mytime=today.toLocaleTimeString();
   var date = year + "-" + month + "-" + day + " " + mytime;   
   document.getElementById("endTime").value = 123;
   document.getElementById("startTime").value = 123;
   
   
   function toDecimal2(x) {      
       var f = parseFloat(x);   //将字符串转换为浮点型      
       if (isNaN(f)) {       //isNaN() 函数用于检查其参数是否是非数字值。  
           return false;      
       }      
       var f = Math.round(x*100)/100;      
       var s = f.toString();      
       var rs = s.indexOf('.');      
       if (rs < 0) {      
           rs = s.length;      
           s += '.';      
       }      
       while (s.length <= rs + 2) {      
           s += '0';      
       }      
       return s; 
   } 
   
   var com=$("#getCommod").val();
   var com2=toDecimal2(com);
   $("#commodityprice_test").val(com2);
</script>
<#include "/common/foot.html"/>
